﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.DBUtility;

namespace BaoJian.Control
{
    /// <summary>
    /// 健康知识
    /// </summary>
    public partial class JKZS : System.Web.UI.UserControl
    {
        public DataSet ds = null;

        //1.营养知识 1条
        //2.膳食指南 4条
        //3.减肥方法 1条
        //4.减肥食谱 2条
        //5.性爱 1条
        //6.中医知识 4条
        //7.老人健身、女性生活、保健常识、婴儿呵护各一条
        private string[] coloumn = new string[10] { "8d4dd410-9c71-4dd8-a983-7c3b51227b7b", "3216a429-0188-42c5-8434-b594a81b20c5", 
                                                    "3f70e368-8f51-4fe7-b744-bf4cc1205ede","d9b3a9d0-505b-4434-b5bb-633d7f16bbc5",
                                                    "DBE2BE2F-5794-486E-B855-FA1AD3190A1B","537a4e0a-a50f-4227-854b-a0a5320a14ef",
                                                    "7a2ad416-8f52-4c4b-b6e4-26245a0c8712","0688f550-e378-4068-8b73-f5a186a3877b",
                                                    "2ae8caf4-d5c6-4144-84b6-7d20a036ff19","5c1741c8-e86d-4754-9313-c22d6bf4f9f4"};
        private int [] count = new int[10]{1,4,1,2,1,4,1,1,1,1};
        private int [] title = new int[10]{15,9,15,9,15,14,15,15,15,15};
       
        protected void Page_Load(object sender, EventArgs e)
        {
             if(!Page.IsPostBack)
             {
                 BindData();
             }
        }
        private void BindData()
        {
            StringBuilder   sb  =  new StringBuilder();
            string sql = "SELECT top {0} oid,left(title,{1}) as Title FROM doc where PID='{2}' and publish=1 order by sid desc ";

            for(int i = 0; i < 10; i++)
            {
                sb.Append(string.Format(sql, count[i], title[i], coloumn[i]));
            }

            ds = DbHelperSQL.Query(sb.ToString());   

        }
    }
}